package org.jsola.hr.helper;

import org.jsola.common.ClassKit;
import org.jsola.hr.dto.TransferAccountsZfbBatchAddDTO;
import org.jsola.hr.dto.TransferAccountsZfbBatchUpdateDTO;
import org.jsola.hr.entity.TransferAccountsZfbBatchDO;
import org.jsola.hr.query.TransferAccountsZfbBatchQuery;
import org.jsola.hr.service.ITransferAccountsZfbBatchService;
import org.jsola.hr.vo.TransferAccountsZfbBatchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Date;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账批次(支付宝)
 *
 * @author zhr
 */
@Component
public class TransferAccountsZfbBatchTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsZfbBatchService transferAccountsZfbBatchService;

    /**
     * 生成add测试数据
     * @return TransferAccountsZfbBatchAddDTO
     */
    public TransferAccountsZfbBatchAddDTO getTransferAccountsZfbBatchAddDTO(){
        TransferAccountsZfbBatchAddDTO transferAccountsZfbBatchAddDTO = new TransferAccountsZfbBatchAddDTO();
        transferAccountsZfbBatchAddDTO.setBatchId(getRandomValue("varchar",32));
        transferAccountsZfbBatchAddDTO.setOrderTitle(getRandomValue("varchar",64));
        transferAccountsZfbBatchAddDTO.setRemark(getRandomValue("varchar",256));
        transferAccountsZfbBatchAddDTO.setBatchTransId(getRandomValue("varchar",100));
        transferAccountsZfbBatchAddDTO.setTimeExpire((Date)ClassKit.getObjectValue(getRandomValue("datetime",0),"java.util.Date"));
        transferAccountsZfbBatchAddDTO.setPayUrl(getRandomValue("text",0));
        transferAccountsZfbBatchAddDTO.setPayUrlTwo(getRandomValue("text",0));
        transferAccountsZfbBatchAddDTO.setPayUrlTwoImage(getRandomValue("varchar",255));
        transferAccountsZfbBatchAddDTO.setPayerUserId(getRandomValue("varchar",64));
        transferAccountsZfbBatchAddDTO.setTotalCount(getRandomValue("varchar",5));
        transferAccountsZfbBatchAddDTO.setSuccessCount(getRandomValue("varchar",5));
        transferAccountsZfbBatchAddDTO.setFailCount(getRandomValue("varchar",5));
        transferAccountsZfbBatchAddDTO.setMoney(getRandomValue("varchar",13));
        transferAccountsZfbBatchAddDTO.setSuccessMoney(getRandomValue("varchar",13));
        transferAccountsZfbBatchAddDTO.setFailMoney(getRandomValue("varchar",13));
        transferAccountsZfbBatchAddDTO.setBatchStatus(getRandomValue("varchar",13));
        transferAccountsZfbBatchAddDTO.setPassbackParams(getRandomValue("varchar",256));
        transferAccountsZfbBatchAddDTO.setDisuseOpUid(getRandomValue("varchar",64));
        transferAccountsZfbBatchAddDTO.setApprovalStatus(getRandomValue("varchar",32));
        transferAccountsZfbBatchAddDTO.setErrorCode(getRandomValue("varchar",100));
        transferAccountsZfbBatchAddDTO.setFailReason(getRandomValue("varchar",200));
        transferAccountsZfbBatchAddDTO.setGmtFinish(getRandomValue("varchar",32));
        transferAccountsZfbBatchAddDTO.setGmtPayFinish(getRandomValue("varchar",32));
        transferAccountsZfbBatchAddDTO.setPayerId(getRandomValue("varchar",64));
        return transferAccountsZfbBatchAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsZfbBatchUpdateDTO
     */
    public TransferAccountsZfbBatchUpdateDTO getTransferAccountsZfbBatchUpdateDTO(TransferAccountsZfbBatchVO transferAccountsZfbBatchVO){
        return transferAccountsZfbBatchService.selectDOById(transferAccountsZfbBatchVO.getId(), SITE_ID).to(TransferAccountsZfbBatchUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsZfbBatchQuery
     */
    public TransferAccountsZfbBatchQuery getTransferAccountsZfbBatchQuery() {
        TransferAccountsZfbBatchQuery transferAccountsZfbBatchQuery = new TransferAccountsZfbBatchQuery();
        List<TransferAccountsZfbBatchDO> transferAccountsZfbBatchDOList = transferAccountsZfbBatchService.list(new TransferAccountsZfbBatchDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsZfbBatchDOList)) {
            TransferAccountsZfbBatchDO transferAccountsZfbBatchDO = transferAccountsZfbBatchDOList.get(0);
            transferAccountsZfbBatchQuery = transferAccountsZfbBatchDO.to(TransferAccountsZfbBatchQuery.class);
        }
        return transferAccountsZfbBatchQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsZfbBatchVO
     */
    public TransferAccountsZfbBatchVO saveTransferAccountsZfbBatchExample(){
        TransferAccountsZfbBatchAddDTO addDTO = this.getTransferAccountsZfbBatchAddDTO();
        TransferAccountsZfbBatchVO transferAccountsZfbBatchVO = transferAccountsZfbBatchService.save(addDTO,buildTokenUser());
        return transferAccountsZfbBatchVO;
    }


}

